package com.dynamixsoftware.printershare.ipp;

import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class IppAttribute
{
  public static final byte TYPE_BOOLEAN = 34;
  public static final byte TYPE_CHARSET = 71;
  public static final byte TYPE_ENUM = 35;
  public static final byte TYPE_INTEGER = 33;
  public static final byte TYPE_KEYWORD = 68;
  public static final byte TYPE_MIME_MEDIA_TYPE = 73;
  public static final byte TYPE_NAME_WITHOUT_LANGUAGE = 66;
  public static final byte TYPE_NATURAL_LANGUAGE = 72;
  public static final byte TYPE_URI = 69;
  public byte[] name;
  public byte tag;
  public byte[] value;
  
  public IppAttribute(byte paramByte)
  {
    this.tag = paramByte;
  }
  
  public IppAttribute(byte paramByte, String paramString, int paramInt)
    throws Exception
  {
    this.tag = paramByte;
    this.name = paramString.getBytes("ASCII");
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    new DataOutputStream(localByteArrayOutputStream).writeInt(paramInt);
    this.value = localByteArrayOutputStream.toByteArray();
  }
  
  public IppAttribute(byte paramByte, String paramString1, String paramString2)
    throws Exception
  {
    this(paramByte, paramString1, paramString2, null);
  }
  
  public IppAttribute(byte paramByte, String paramString1, String paramString2, String paramString3)
    throws Exception
  {
    this.tag = paramByte;
    this.name = paramString1.getBytes("ASCII");
    if (paramString3 == null) {
      paramString3 = "ASCII";
    }
    this.value = paramString2.getBytes(paramString3);
  }
  
  public IppAttribute(byte paramByte, String paramString, boolean paramBoolean)
    throws Exception
  {
	byte value = 1;
    this.tag = paramByte;
    this.name = paramString.getBytes("ASCII");
    this.value = new byte[value];
    byte[] arrayOfByte = this.value;
    if (!paramBoolean) {
    	value = 0;
    }
    arrayOfByte[0] = (byte)value;
  }
  
  void readFromStream(DataInputStream var1) throws IOException {
      short var2 = var1.readShort();
      if(var2 > 0) {
         this.name = new byte[var2];
         var1.readFully(this.name);
      } else {
         this.name = null;
      }

      short var3 = var1.readShort();
      if(var3 > 0) {
         this.value = new byte[var3];
         var1.readFully(this.value);
      } else {
         this.value = null;
      }
   }

  
  void writeToStream(DataOutputStream paramDataOutputStream)
    throws IOException
  {
    paramDataOutputStream.writeShort(this.name.length);
    paramDataOutputStream.write(this.name);
    paramDataOutputStream.writeShort(this.value.length);
    paramDataOutputStream.write(this.value);
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.ipp.IppAttribute
 * JD-Core Version:    0.7.0.1
 */